package cn.liumouren.jzxd.controller;


import cn.liumouren.jzxd.common.utils.R;
import cn.liumouren.jzxd.entity.Lunbotu;
import cn.liumouren.jzxd.service.LunbotuService;
import cn.liumouren.jzxd.utils.QueryUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * (Lunbotu)表控制层
 *
 * @author daniel liu
 * @since 2021-03-09 22:56:48
 */
@RestController
@RequestMapping("lunbotu")
public class LunbotuController {

    @Autowired
    private LunbotuService lunbotuService;

    /**
     * 万能查询
     */
    @GetMapping
    public R findAll() {
        return R.ok("查询成功", lunbotuService.list());
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/{id}")
    public R selectOne(@PathVariable Serializable id) {
        return R.ok("查询成功", lunbotuService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param lunbotu 实体对象
     * @return 新增结果
     */
    @PostMapping
    public R insert(@RequestBody Lunbotu lunbotu) {
        lunbotuService.save(lunbotu);
        return R.ok("新增成功");
    }

    /**
     * 修改数据
     *
     * @param lunbotu 实体对象
     * @return 修改结果
     */
    @PutMapping
    public R update(@RequestBody Lunbotu lunbotu) {
        lunbotuService.updateById(lunbotu);
        return R.ok("更新成功");
    }

    /**
     * 批量删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    public R delete(@RequestBody List<Serializable> idList) {
        lunbotuService.removeByIds(idList);
        return R.ok("删除成功");
    }
}
